package com.sinothk.special.buyer.popular.user.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sinothk.special.buyer.popular.user.entity.PopularBlogDTO;
import com.sinothk.special.buyer.popular.user.entity.PopularUser;
import com.sinothk.special.buyer.popular.user.entity.PopularUserDTO;
import com.sinothk.special.buyer.popular.user.entity.PopularUserSearchVO;
import com.sinothk.special.buyer.popular.user.mapper.PopularUserMapper;
import com.sinothk.special.buyer.popular.user.service.IPopularUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description: 热门个人推荐
 * @Author: Liangyt
 * @Date: 2022-06-17
 * @Version: V1.0
 */
@Service
public class PopularUserServiceImpl extends ServiceImpl<PopularUserMapper, PopularUser> implements IPopularUserService {

    @Resource
    private PopularUserMapper popularUserMapper;

    @Override
    public IPage<PopularUserDTO> popularUserPage(Page<PopularUserDTO> page, PopularUserSearchVO searchVO) {

        int count = popularUserMapper.popularUserPageCount(searchVO);
        if (count < 100) {
            searchVO.setNeedSysDate(1);
        } else {
            searchVO.setNeedSysDate(0);
        }

        return popularUserMapper.popularUserPage(page, searchVO);
    }

    @Override
    public IPage<PopularBlogDTO> popularBlogPage(Page<PopularBlogDTO> page, PopularUserSearchVO searchVO) {
        return popularUserMapper.popularBlogPage(page, searchVO);
    }
}
